﻿/*
版权所有：版权所有(C) 2010，刘建新
文件编号：M01_BaseHomePicsBll.cs
文件名称：BaseHomePicsBll.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2010/12/21
作　　者：
内容摘要：表[Base_Home_Pics]业务操作类
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Eis51.CampanyCMS.Model.BaseInfoMng;
using System.IO;
using Eis51.CampanyCMS.Model;
using Eis51.CampanyCMS.Access.BaseInfoMng;
using System.Collections;

namespace Eis51.CampanyCMS.Business.BaseInfoMng
{
    /// <summary>
	/// BaseHomePics的BLL 自定义方法
	/// 该BLL已经生成了基本的业务操作，在自动生成的方法中已经提供了事务机制
	/// </summary>
    public partial class BaseHomePicsBLL : BaseBLL<BaseHomePics>
    {
        /// <summary>
        /// delete
        /// </summary>
        /// <param name="obj"></param>
        public void DeleteObj(BaseHomePics obj)
        {
            //FILENAME[（固定在/UploadFile/|Createby|/Img/|FILENAME|）]
            if (obj.Filename != string.Empty)
            {
                //File_path1[文件地址1（固定在/UploadFile/|Createby|/File/|File_path1|）]
                string path = System.Web.HttpContext.Current.Server.MapPath("~/UploadFile/" + obj.Createby + "/Img/" + obj.Filename);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
            this.Delete(obj);
        }
        /// <summary>
        /// tijiao
        /// </summary>
        /// <param name="c"></param>
        public void Submit(BaseHomePics c)
        {
            if (c.BaseHomePicsId > 0)
            {

                BaseHomePicsBLL.GetInstance().Update(c);
            }
            else
            {                
                BaseHomePicsBLL.GetInstance().Insert(c);
            }
        }
    }


    #region 代码自动生成
    /// <summary>
    /// BaseHomePics的BLL
    /// 该BLL已经生成了基本的业务操作，在自动生成的方法中已经提供了事务机制
    /// </summary>
    public partial class BaseHomePicsBLL : BaseBLL<BaseHomePics>
    {
        #region 自动生成代码：取得相关实体

        /// <summary>
        /// 方法名称: BaseHomePicsBLL
        /// 内容摘要: 构造函数进行初始化
        /// </summary>
        protected BaseHomePicsBLL()
        {
        }
        private static volatile BaseHomePicsBLL m_instance = null;
        /// <summary>
        /// 方法名称: GetInstance
        /// 内容摘要: 取得 BaseHomePicsBLL 对象
        /// </summary>
        /// <returns>返回一个已经存在的实体</returns>
        public static BaseHomePicsBLL GetInstance()
        {
            // 通用的必要代码 iBatisNet双校检机制,如果实例不存在
            if (m_instance == null)
            {
                lock (typeof(BaseHomePicsBLL))
                {

                    // 如果实例不存在
                    if (m_instance == null)
                    {

                        // 创建一个的实例
                        m_instance = new BaseHomePicsBLL();
                    }
                }
            }

            // 返回业务逻辑对象
            return m_instance;
        }

        #endregion

        #region 自动生成代码：基本业务公开函数

        /// <summary>
        /// 方法名称: Get
        /// 内容摘要: 由键值获取一个实体对象
        /// </summary>
        /// <returns>BaseHomePics</returns>
        public BaseHomePics Get(BaseHomePics.Key key)
        {

            return BaseHomePicsDao.GetInstance().SelectByID(key);
        }
        /// <summary>
        /// 方法名称: Select
        /// 内容摘要: 基本查询，不带任何条件的查询
        /// </summary>
        public IList Select()
        {
            return BaseHomePicsDao.GetInstance().SelectAll();
        }
        /// <summary>
        /// 方法名称: Insert
        /// 内容摘要: 插入一条新纪录
        /// </summary>
        /// <returns>int</returns>
        public int Insert(BaseHomePics obj)
        {
            int result = 0;
            try
            {
                result = BaseHomePicsDao.GetInstance().Insert(obj);
            }
            catch (Exception e)
            {
                throw e;
            }
            return result;
        }

        /// <summary>
        /// 方法名称: Update
        /// 内容摘要: 更新一条新纪录
        /// </summary>
        /// <returns>int</returns>
        public int Update(BaseHomePics obj)
        {
            BaseHomePicsDao.GetInstance().Update(obj);
            return 1;
        }

        /// <summary>
        /// 方法名称: Delete
        /// 内容摘要: 删除一条新纪录
        /// </summary>
        /// <returns>int</returns>
        public int Delete(BaseHomePics obj)
        {
            BaseHomePicsDao.GetInstance().DeleteByID(new BaseHomePics.Key(obj.BaseHomePicsId));
            return 1;
        }

        #endregion

    }
    #endregion
}